package com.gopi.utilities.gui;

import java.awt.GridBagConstraints;

import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class PropertySheet 
{
	public static final int LABEL = 0;
	public static final int SELECTABLE_LABEL = 1;
	public static final int EDITABLE_FIELD = 2;
	public static final int EDITABLE_AREA = 3;
	public static final int ICON_AREA = 4;
	public static final int UNEDITABLE_TEXT = 5;	
	
	public static JComponent addEntry(JComponent container,int type,String aboutKey,String detail,GridBagConstraints gc)
	{
		GridBagConstraints gc1 = (GridBagConstraints)gc.clone();
		JComponent comp = null;
		gc.gridx = 0;
		if(type!=ICON_AREA)
			container.add(new JLabel(aboutKey),gc);
		else
			container.add(new JLabel(ImageLoader.getInstance().getIconFromFile(aboutKey)),gc);
		gc.gridx++;
		gc.weightx = 100;
		gc.gridwidth = GridBagConstraints.HORIZONTAL;
		switch(type)
		{
		case LABEL:
			container.add(comp = new JLabel(detail),gc);
			break;
		case SELECTABLE_LABEL:
		case EDITABLE_FIELD:	
		{
			container.add(comp = GuiFactory.createBorderlessTextField(25),gc);
			GuiFactory.setText(comp,detail);
			GuiFactory.setEditable(comp,type==EDITABLE_FIELD);
			comp.setBackground(container.getBackground());
			break;
		}
		case ICON_AREA:			
		case UNEDITABLE_TEXT:
		{
			container.add(comp = GuiFactory.createUnEditableTextField(23),gc);
			GuiFactory.setText(comp,detail);
			break;
		}
		}
		gc.gridy++;
		gc.anchor = gc1.anchor;
		gc.weightx = gc1.weightx;
		gc.gridwidth = gc1.gridwidth;
		
		return comp;
	}
}
